package cn.zn.modules.pz.cur.controller;

import cn.zn.framework.common.utils.R;
import cn.zn.modules.pz.cur.entity.TpSpecial;
import cn.zn.modules.pz.cur.service.TpSpecialService;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.validation.Valid;

@RestController
@RequestMapping("pz/cur/special")
public class TpSpecialController {

    @Autowired
    private TpSpecialService tpSpecialService;

    @GetMapping("{mainId}")
    public R info(@PathVariable("mainId") String mainId) {
        return R.ok().put("special", tpSpecialService.findByMainId(mainId));
    }

    @PostMapping("save")
    public R save(@Valid @RequestBody TpSpecial tpSpecial) {
        tpSpecialService.saveSpecial(tpSpecial);
        return R.ok();
    }

    @PostMapping("update")
    public R update(@Valid @RequestBody TpSpecial tpSpecial) {
        tpSpecialService.updateSpecial(tpSpecial);
        return R.ok();
    }

    @DeleteMapping("{mainId}")
    public R delete(@PathVariable("mainId") String mainId) {
        tpSpecialService.deleteSpecial(mainId);
        return R.ok();
    }
}
